#ifndef RENDERPSEUDOTHREAD_H
#define RENDERPSEUDOTHREAD_H

#include <QPainter>
#include <QImage>
#include <QVector>

#include "Vector3D.h"
#include "triangle.h"
#include "pseudothread.h"

class RenderPseudoThread : public PseudoThread
{
    Q_OBJECT

public:
    RenderPseudoThread();
    ~RenderPseudoThread();
    void populate(QVector<triangle*> triangles, const QVector<float> &vertexHeight, const QVector<QPointF> &vertices, float aMin, float aMax);
    void render(QSize size, QMatrix matrix );

signals:
    void workDone(const QImage &aImage);

private:
    bool loopStep();

    void drawTriangle(const Vector3D& v1, const Vector3D& v2, const Vector3D& v3);

    QVector<triangle*> triangles;
    QVector<float> vertexHeight;
    QVector<QPointF> vertices;
    float min;
    float max;

    QMatrix matrix;     // world matrix for actual zoom state, TODO: better name like currentWorldMatrix
    QSize size;
    bool populated;

    // temporary variables used in computation
    QImage image;
    QPainter* painter;
    QVector<triangle*>::iterator it;
};

#endif // RENDERPSEUDOTHREAD_H
